// MyFamily - XML based genealogy program.
// Copyright (C) 2006  Doug Swisher
// See the file COPYING.txt for license details.

using System;
using System.Windows.Forms;
using System.Diagnostics;

using DataModel;


namespace CommonGui
{
    public partial class GedComImportResultsDialog : Form
    {
        private GedComImportResults importResults;
        private GedComReadResults gedResults;

        public GedComImportResultsDialog(GedComImportResults results, GedComReadResults gedResults)
        {
            this.importResults = results;
            this.gedResults = gedResults;

            InitializeComponent();
        }


        private void GedComImportResultsDialog_Load(object sender, EventArgs e)
        {
            this.IndividualCountTextBox.Text = this.importResults.IndividualCount.ToString();
            this.PersonaCountTextBox.Text = this.importResults.PersonaCount.ToString();
            this.ExtractCountTextBox.Text = this.importResults.ExtractCount.ToString();
            this.SourceCountTextBox.Text = this.importResults.SourceCount.ToString();

            this.InputFileTextBox.Text = this.importResults.InputFileInfo.FullName;

            int totalWarnings = this.importResults.WarningCount + this.gedResults.WarningCount;
            this.WarningCountTextBox.Text = totalWarnings.ToString();

            foreach (string message in importResults.Messages)
            {
                this.MessagesTextBox.AppendText(message + "\r\n");
            }

            foreach (string message in gedResults.Messages)
            {
                this.MessagesTextBox.AppendText(message + "\r\n");
            }
        }


        private void ViewInputButton_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                Process.Start(this.importResults.InputFileInfo.FullName);
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.ToString(), "GEDCOM view launch threw an exception");
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
    }
}